package com.api.user.controller;

import com.api.core.config.AuthUser;
import com.api.core.controller.Ctrl;
import com.api.core.response.Result;
import com.api.core.response.ResultGenerator;
import com.api.user.model.ReferralLog;
import com.api.user.service.ReferralLogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.entity.Condition;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

import com.api.core.annotation.PowerEnable;
import io.swagger.annotations.*;


/**
 * Created by wanghuiwen on 2022/05/11.
 */
@PowerEnable(name = "referral_log", url = "/referral/log")
@Api(value = "referral_log", tags = {"referral_log"})
@RestController
@RequestMapping("/referral/log")
public class ReferralLogController extends Ctrl {
    @Resource
    private ReferralLogService referralLogService;

    @ApiOperation(value = "referral_log添加", tags = {"referral_log"}, notes = "referral_log添加")
    @PostMapping(value = "/user")
    public Result add(Authentication authentication) {
        AuthUser authUser = getAuthUser(authentication);
        Map<String, Object> res = referralLogService.user(authUser.getId());
        return ResultGenerator.genSuccessResult(res);
    }


    @ApiOperation(value = "referral_log添加", tags = {"referral_log"}, notes = "referral_log添加")
    @PostMapping(value = "/list")
    public Result list(@RequestParam Long userId, @RequestParam(defaultValue = "0") Integer page,
                       @RequestParam(defaultValue = "10") Integer size) {
        return referralLogService.list(userId,page,size);
    }
}
